package com.zhangmeng.online.exam.entity;

import com.zhangmeng.online.exam.entity.baseEntity.BaseEntity;
import lombok.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 考试答案 (考试答案)
 * @author zm
 * @date 2025/4/17 16:31
 * @version: 1.0
 */
@NoArgsConstructor
@ToString(exclude = {"exam", "question", "questionOptions"})
@Getter
@Setter
@AllArgsConstructor
@Entity
@Table(name = "exam_answer")
public class ExamAnswer extends BaseEntity<Long> {

    @ManyToOne
    private Exam exam;

    @ManyToOne
    private Paper paper;//试卷

    @ManyToOne
    private Question question;//问题

    @ManyToMany(targetEntity = QuestionOption.class)
    @JoinTable(name = "exam_answer_question_option", joinColumns = @JoinColumn(name = "exam_answer_id"), inverseJoinColumns = @JoinColumn(name = "question_option_id"))
    private List<QuestionOption> questionOptions = new ArrayList<>();//答案选项

    private String answer;//答案

}
